<template>
    <div class="cmdcfg">
        <exInput v-model.number="x1" label="x" width="75" size="mini"></exInput>
        <exInput v-model.number="y1" label="y" width="75" size="mini"></exInput>
    </div>
</template>


<script>

export default {
    props: {
        cmdInfo: { type: Object, default: {} },
        devInfo:{ type: Object, default: {} },
    },
    data() {
        return {
            x1 : this.cmdInfo.x1 || "",
            y1 : this.cmdInfo.y1 || "",
        };
    },
    inject: ['doDevCmd','doNextCmd'],
     

    mounted() {
    },

    methods: {
        setByDevInfo(){
            this.x1 = this.devInfo.clickX || "";
            this.y1 = this.devInfo.clickY || "";
        },
        saveCmd(){
            this.cmdInfo.x1 = this.x1;
            this.cmdInfo.y1 = this.y1;
        },
        preCheck(){
            if(!this.x1){
                this.$message.error("请输入X坐标")
                return false;
            }
            if(!this.y1){
                this.$message.error("请输入Y坐标")
                return false;
            }
            return true;
        },
        runCmd(isOnce){
            if(!this.preCheck()){
                this.$emit("stopRun")
                return;
            }
            this.preView();
            this.doDevCmd(`adb shell input tap ${this.x1*this.devInfo.devBet} ${this.y1*this.devInfo.devBet} `);
            this.$emit("stopRun")
            if(isOnce!==true) this.doNextCmd();
        },
        preView(){
            this.devInfo.clickX = this.x1;
            this.devInfo.clickY = this.y1;
        },
    }
}
</script>

<style lang="less" scoped>
    .cmdcfg{
        display: inline-block;
    }
</style>
